package com.bdy.lm.taximanager.rfid;

/**
 * Created by Administrator on 2016/9/13 0013.
 */

import android.util.Log;

import com.frank.rfid.RFIDLib;

// 全局管理器
public class TotalManager {
    private static final String TAG = "TotalManager";

    private static TotalManager theInstance = null;
    private RFIDDelegate mRFIDDelegate = null;

    // 构造
    private TotalManager() {
    }

    // 返回TotalManager的实例
    public static TotalManager instance() {
        if (theInstance == null) {
            theInstance = new TotalManager();
        }
        return theInstance;
    }

    // 在myApplication中启动管理器
    public boolean start() {
        Log.i(TAG, "Total manager start...");
        mRFIDDelegate = new RFIDDelegate();
        RFIDLib.initialize(mRFIDDelegate);
        return true;
    }

    // 在实现RFIDCallback接口，需要接收卡号的地方，设置回调
    public void setRFIDCallback(RFIDCallback callback) {
        if (mRFIDDelegate != null)
            mRFIDDelegate.setCallback(callback);
    }

    // 停止管理器
    public void stop() {
        RFIDLib.dealloc();
        Log.i(TAG, "Total manager stoped.");
    }


}
